cmake_minimum_required(VERSION 3.0.0)
project(SPlugin VERSION 0.1.0 LANGUAGES C CXX)

option(SPLUGIN_TEST_ENABLED "test enabled")

set(SPLUGIN_TEST_ENABLED ON)
message(STATUS SPLUGIN_TEST_ENABLED=${SPLUGIN_TEST_ENABLED})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

set(INCLUDE_DIR 
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/reflect/include
)


include(CTest)
enable_testing()

if(NOT TARGET reflect)
    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/reflect)
    file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/reflect/include/ DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include)
endif()


file(GLOB_RECURSE SOURCE_FILE src/*.cpp)
file(GLOB_RECURSE HEADER_FILE src/*.h)
file(COPY ${HEADER_FILE} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include)

include_directories(${INCLUDE_DIR})

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILE})

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
    target_link_libraries(${PROJECT_NAME} dxyreflect dl)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
    target_link_libraries(${PROJECT_NAME} dxyreflect)
endif()
########
# TEST #
########
if(SPLUGIN_TEST_ENABLED)
    add_subdirectory(test)
endif()




